# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html

from doubanMovie.items import DoubanmovieItem
from scrapy.conf import settings

import pymongo

class DoubanmoviePipeline(object):
    def __init__(self):
        host = settings['MONGODB_HOST']
        port = settings['MONGODB_PORT']
        dbName = settings['MONGODB_DBNAME']

        client = pymongo.MongoClient()
        tdb = client[dbName]
        self.post = tdb[settings['MONGODB_DOCNAME']]

    def process_item(self, item, spider):
        StarInfo = dict(item)
        self.post.insert(StarInfo)

        # self.tdb['movie_info'].insert(movieInfo)



